package spring.cloud.tasks.executor.name_space.executor.task;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import spring.cloud.tasks.executor.name_space.executor.task.task_listener.task_configuration.TaskConfiguration;
import spring.cloud.tasks.executor.name_space.executor.tasks_runtime_info.task_item_execute.TaskItemExecuteRuntimeContext;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 任务运行上下文
 */
@Slf4j
@Setter
@Getter
public class TaskExecuteContext {
    private String nameSpace;
    private String executorId;
    private String taskId;

    private TaskConfiguration taskConfiguration;

    /**
     * Job超时时间(秒)
     */
    private Integer secondAfterTaskStopCommandInstructed;
    private Integer timeoutMinutes;
    private int initRenewalTimeMinutes;
    private int maxRenewalTimeMinutes;
    /**
     * 分片总数.
     */
    private int taskItemTotalCount;
    /**
     * 运行在本任务服务器的分片序列号集合.
     */

    private ConcurrentHashMap<String, List<Integer>> taskInstanceIdToItemIndexListMap = new ConcurrentHashMap<>();
    private List<TaskItemExecuteRuntimeContext> taskItemExecuteRuntimeContextList = new ArrayList<TaskItemExecuteRuntimeContext>();
    /**
     * 运行在本任务项的分片序列号和个性化参数列表.
     */
    private Map<Integer, String> taskItemIndexToTaskItemParameterMap = new HashMap<Integer, String>();
    /**
     * 任务运行日志, key为分片项
     */
    private Map<Integer, String> logMap = new HashMap<>();
    /**
     * 任务自定义参数. 可以配置多个相同的任务, 但是用不同的参数作为不同的调度实例.
     */
    private String propertiesString;


}
